﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;


namespace C7
{
	/// <summary>
	/// Interaction logic for EnhancedWelcomeScreen.xaml
	/// </summary>
	public partial class EnhancedWelcomeScreen : UserControl
	{
        Storyboard sbFadeInAndGrow;
        Storyboard sbrevFadeInAndGrow;
        Storyboard sbTextPulse;
		public EnhancedWelcomeScreen()
		{
			this.InitializeComponent();

            if (true) // Check if there are reservations for this table
            {
                tbReservationMessage.Text += ""; // Here goes the time of the reservation
                vbForReservationResize.Visibility = Visibility.Visible;
            }

            sbFadeInAndGrow = (Storyboard)TryFindResource("sbFadeInAndGrow");
            sbrevFadeInAndGrow = (Storyboard)TryFindResource("sbrevFadeInAndGrow");
            sbTextPulse = (Storyboard)TryFindResource("sbTextPulse");
            sbFadeInAndGrow.Completed += new EventHandler(sb_Completed);
            sbTextPulse.Completed += new EventHandler(sbPulse_Completed);
            sbrevFadeInAndGrow.Completed += new EventHandler(sbrevFade_Completed);
            this.Loaded += new RoutedEventHandler(EnhancedWelcomeScreen_Loaded);
		}

        void EnhancedWelcomeScreen_Loaded(object sender, RoutedEventArgs e)
        {
            //var sbFadeInAndGrow = (Storyboard)TryFindResource("sbFadeInAndGrow");
            sbFadeInAndGrow.Begin(this, true);
        }

        void sbrevFade_Completed(object sender, EventArgs e)
        {
            //var sbFade = (Storyboard)TryFindResource("sbFadeInAndGrow");
            sbFadeInAndGrow.Begin(this, true);
        }

        void sbPulse_Completed(object sender, EventArgs e)
        {
            //var sbrevFade = (Storyboard)TryFindResource("sbrevFadeInAndGrow");
            sbrevFadeInAndGrow.Begin(this, true);
        }

        void sb_Completed(object sender, EventArgs e)
        {
            //var sb = (Storyboard)TryFindResource("sbTextPulse");
            sbTextPulse.Begin(this, true);
        }

        private void ReservationMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var WindowOps = new WindowOperations();
            WindowOps.PauseOrResumeAllAnimations(this, true);
            //WindowOps.StopAllAnimations(LayoutRoot);
            WindowOps.FadeBackgroundAndDisable(LayoutRoot);
            var lw = new LoginWindow();
            grdWindows.Children.Add(lw);
        }
	}
}